/*
 * MIT License
 *
 * Copyright (c) 2024-2048 冰羽
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package cn.star.framework.rbac.core;

import cn.star.framework.core.IdEntity;
import cn.star.framework.identity.User;
import cn.star.framework.identity.UserIdentity;
import java.util.Date;

/**
 * Rbac 用户<br>
 *
 * @author zhaoweiping
 *     <p style='color: red'>Created on 2024-09-23 11:06:00
 * @since 3.0.0
 */
public interface IRbacUser<G extends UserIdentity> extends IdEntity<String>, User<G> {
  /**
   * 设置账号
   *
   * @param username 账号
   */
  void setUsername(String username);

  /**
   * 获取账号
   *
   * @return 账号
   */
  @Override
  String getUsername();

  /**
   * 设置密码
   *
   * @param password 密码
   */
  void setPassword(String password);

  /**
   * 获取密码
   *
   * @return 密码
   */
  @Override
  String getPassword();

  /**
   * 设置姓名
   *
   * @param name 姓名
   */
  void setName(String name);

  /**
   * 获取姓名
   *
   * @return 姓名
   */
  String getName();

  /**
   * 设置性别
   *
   * @param gender 性别
   */
  void setGender(String gender);

  /**
   * 获取性别
   *
   * @return 性别
   */
  String getGender();

  /**
   * 设置生日
   *
   * @param birthday 生日
   */
  void setBirthday(Date birthday);

  /**
   * 获取生日
   *
   * @return 生日
   */
  Date getBirthday();

  /**
   * 设置身份证号
   *
   * @param identityCard 身份证号
   */
  void setIdentityCard(String identityCard);

  /**
   * 获取身份证号
   *
   * @return 身份证号
   */
  String getIdentityCard();

  /**
   * 设置电话号码
   *
   * @param phone 电话号码
   */
  void setPhone(String phone);

  /**
   * 获取电话号码
   *
   * @return 电话号码
   */
  String getPhone();

  /**
   * 设置手机号码
   *
   * @param mobile 手机号码
   */
  void setMobile(String mobile);

  /**
   * 获取手机号码
   *
   * @return 手机号码
   */
  String getMobile();

  /**
   * 设置邮箱地址
   *
   * @param email 邮箱地址
   */
  void setEmail(String email);

  /**
   * 获取邮箱地址
   *
   * @return 邮箱地址
   */
  String getEmail();

  // Spring Security UserDetails

  /**
   * accountNonExpired<br>
   * Indicates whether the user's account has expired. An expired account cannot be authenticated.
   *
   * @return <code>true</code> if the user's account is valid (ie non-expired), <code>false</code>
   *     if no longer valid (ie expired)
   */
  Date getAccountExpiredTime();

  /**
   * 设置账号过期时间<br>
   * 账号是否过期，过期的账号不能通过身份验证<br>
   * true表示未过期，false表示已过期
   *
   * @param time
   */
  void setAccountExpiredTime(Date time);

  /**
   * Indicates whether the user is lock or unlocked. A lock user cannot be authenticated.
   *
   * @return <code>true</code> if the user is not lock, <code>false</code> otherwise
   */
  boolean isAccountNonLocked();

  /**
   * 账号是否锁定，锁定的账号不能通过身份验证<br>
   * true表示未锁定，false表示已锁定
   *
   * @param locked
   */
  void setAccountNonLocked(boolean locked);

  /**
   * 获取密码错误次数
   *
   * @return
   */
  int getPasswordErrorTimes();

  /**
   * 设置密码错误次数
   *
   * @param passwordErrorTimes
   */
  void setPasswordErrorTimes(int passwordErrorTimes);

  /**
   * credentialsNonExpired<br>
   * Indicates whether the user's credentials (password) has expired. Expired credentials prevent
   * authentication.
   *
   * @return <code>true</code> if the user's credentials are valid (ie non-expired), <code>false
   *     </code> if no longer valid (ie expired)
   */
  Date getPasswordModifyTime();

  /**
   * 修改密码时间<br>
   * 用户凭据(密码)是否过期，过期的账号不能通过身份验证<br>
   * true表示未过期，false表示已过期
   *
   * @param time
   */
  void setPasswordModifyTime(Date time);

  /**
   * Indicates whether the user is enabled or disabled. A disabled user cannot be authenticated.
   *
   * @return <code>true</code> if the user is enabled, <code>false</code> otherwise
   */
  boolean isEnabled();

  /**
   * 用户是否启用，禁用的用户不能通过身份验证<br>
   * true表示启用，false表示禁用
   *
   * @param enabled
   */
  void setEnabled(boolean enabled);
}
